﻿/*
* This software is the confidential and proprietary
* information of NetBay
* Such confidential information should not be disclosed
* NetBay copyright(c) 2011
*/
#region
using System;
using System.Data;
using System.ComponentModel;
using NetBay.Core.Log;
using NetBay.Core.DataAccess;
using NetBay.Core.Extensions;

#endregion

namespace Rio.Manager.DataAccess
{
    /// <summary>
    /// DataAcces for Dashboard
    /// </summary>
    public class DA_DashBoard
    {
        #region Enums
        public enum DbFunction
        {
            [DescriptionAttribute("")]

            None,
            [DescriptionAttribute("P_REPORT_MASS_IMPORT_TOTAL")]

            GetReportMassImportTotal,
            [DescriptionAttribute("P_REPORT_MASS_IMPORT")]

            GetReportMassImportByOperator,
        }

        #endregion

        #region Function

        /// <summary>
        /// Get numerization resum by operator
        /// </summary>
        /// <param name="StartDate">Starting Date</param>
        /// <param name="EndDate">endingDate</param>
        /// <returns></returns>
        public static IDataReader GetNumerizationReportByOperator(DateTime StartDate, DateTime EndDate)
        {
            try
            {
                LogManager.Instance().LogDebug("(p_dStartDate<" + StartDate.ToString() + ">)(p_dEndDate<" + EndDate.ToString() + ">)");

                var db = DbHelper.DataBase;
                var dbCommand = db.GetNewCommand(DbFunction.GetReportMassImportByOperator.szGetDescription());

                db.AddInParameter(dbCommand, "p_dStartDate", DbType.String, StartDate.ToShortDateString());
                db.AddInParameter(dbCommand, "p_dEndDate", DbType.String, EndDate.ToShortDateString());

                return db.ExecuteReader(dbCommand);
            }
            catch (Exception ex)
            {
                LogManager.Instance().LogError("DA_DASHBOARD --> GetNumerizationResumByOperator exception[" + ex.Message + "]");
                return null;
            }
        }

        /// <summary>
        /// Get global numerization resum
        /// </summary>
        /// <param name="StartDate">Starting Date</param>
        /// <param name="EndDate">endingDate</param>
        /// <returns></returns>
        public static IDataReader GetNumerizationReport(DateTime StartDate, DateTime EndDate)
        {
            try
            {
                LogManager.Instance().LogDebug("(p_dStartDate<" + StartDate.ToString() + ">)(p_dEndDate<" + EndDate.ToString() + ">)");
                var db = DbHelper.DataBase;

                var dbCommand = db.GetNewCommand(DbFunction.GetReportMassImportTotal.szGetDescription());
                db.AddInParameter(dbCommand, "p_dStartDate", DbType.String, StartDate.ToShortDateString());
                db.AddInParameter(dbCommand, "p_dEndDate", DbType.String, EndDate.ToShortDateString());

                return db.ExecuteReader(dbCommand);
            }
            catch (Exception ex)
            {
                LogManager.Instance().LogError("DA_DASHBOARD --> GetNumerizationResum exception[" + ex.Message + "]");
                return null;
            }
        }
        #endregion
    }
}